class PCE_Products_DEV extends HTMLElement{ constructor(){ super(); this.progress = 0; this.parser = new DOMParser(); this.productsList = []; this.data = []; this.perRow = this.dataset.row; this.limit = this.dataset.limit; this.sortType = this.dataset.sort; this.tagsFilter = []; this.tagListActive = document.querySelectorAll('#CollectionSidebar-v2 .tag-list--active-tags'); this.currentPage = 1; this.productUrl = this.dataset.producturl; this.productsContainer = this.getElementsByClassName('products-container')[0]; this.placeholder = this.getElementsByClassName("grid__item--placeholder")[0]; this.initData(); this.addPriceProducts(this.productsList); this.btnOpenFilterMobile = document.getElementsByClassName('js-drawer-open-collection-filters')[0]; this.btnOpenFilterText = this.btnOpenFilterMobile.querySelector(".btn-filter-text"); this.sortSelect = document.getElementById('SortBy'); this.sortSelect.addEventListener('click', this.showSortList.bind(this)); this.sortItems = document.querySelectorAll('#sortby-panel .sortby-list .sortby-item '); Array.from(this.sortItems).forEach(function(element){ element.addEventListener("click", this.sortHandler.bind(this)); }, this); if(this.productsList.length == 0){ this.classList.add("no-product"); } this.render(); // this.createPagination(); this.filterContainer = document.getElementsByClassName('grid__item--sidebar')[0]; this.filterItems = this.filterContainer.querySelectorAll('.tag span'); this.checkFilterItems(); Array.from(this.filterItems).forEach(function(element){ element.addEventListener("click", this.getTagsFilter.bind(this)); }, this); } addPriceProducts(data){ this.newData = []; data.map(function (rv) { try { let url = this.dataset.producturl.replace("PLACEHOLDER", rv.handle); fetch(url) .then(response => response.text()) .then(result => { let product = JSON.parse(result).product; let productID = product.id; let productHandle = product.handle; let productTitle = product.title; let productPrice = product.variants[0].price; let productTags = product.tags; let productFormat = { "id": productID, "handle": productHandle, "title": productTitle, "price": productPrice, "tags": productTags } this.newData.push(productFormat); }) .catch(error => { return false; }); } catch (e) { return { status: 404, responseText: e.message } } }.bind(this)); } initData(){ this.data = []; let p = ''; try{ p = JSON.parse('{"handle":"100-invisible-iphone-charging-dock-hidden-spy-camera","title":"100% Invisible iPhone Charging Dock Hidden Spy Camera","status":"ACTIVE","tags":["Application_IOT Living","Battery Capacity_N\/A","Brand_Awaretech","Camera Type_Charging Dock","Camera Type_Hidden","Camera Type_Nanny","Camera Type_Spy Camera","Collection_Spy Camera","Connectivity_WiFi\/Wireless","Features_App Push Notification","Features_Motion Activated","Features_Smartphone App","Field Of View_90 - 120 degrees","Live View_View Live Video","Location_Bedroom","Location_Dining Room","Location_Indoor","Location_Living Room","Location_Nursing Home","Location_Office \/ Business","OS Compatibility_Android","OS Compatibility_IOS","Power Source_Plug In","Recording Source_Audio + Video","Sensor_CMOS","Storage - Maximum Capacity_128 Gb (16 Hrs Recording)","Storage Type_Cloud Recording (In-App)","Storage Type_Memory Card","Video Resolution - Max_Full HD 1080p","Viewing_Remote View"]}'); this.productsList.push(p); p = JSON.parse('{"handle":"lawmate-pv-dy20i-diy-hidden-camera-dvr","title":"LawMate\u00ae PV-DY20i DIY Hidden Camera DVR","status":"ACTIVE","tags":["Application_PV Cam Viewer","Battery Capacity_500 mAH","Brand_LawMate\u00ae","Camera Megapixels_2MP","Camera Type_Hidden","Camera Type_Mini","Camera Type_Nanny","Camera Type_Pinhole","Camera Type_Spy Camera","Collection_Spy Camera","Connectivity_WiFi\/Wireless","DIY_DIY","Features_Construction Time Lapse","Features_Motion Activated","Features_Smartphone App","Field Of View_0 - 90 degrees","Lens_3 mega piexels 1\/3''","Live View_View Live Video","Location_Indoor","Location_Office \/ Business","Location_Outdoor","Night Vision Range_0-10 Metres","OS Compatibility_Android","OS Compatibility_IOS","OS Compatibility_Windows","Power Source_Battery","Recording Source_Audio + Video","Sensor_CMOS","Storage - Maximum Capacity_32 Gb (4 Hrs Recording)","Storage Type_Cloud Recording (In-App)","Storage Type_Memory Card","Video Resolution - Max_Full HD 1080p","Viewing_Remote View","Zoom_Digital"]}'); this.productsList.push(p); p = JSON.parse('{"handle":"gf-h100-smart-clock-hd-hidden-camera","title":"UPGRADE Smart Clock Alarm HD Hidden Camera with Radio Speaker","status":"ACTIVE","tags":["Application_IOT Living","Brand_Awaretech","Camera Type_Clock","Camera Type_Hidden","Camera Type_Nanny","Camera Type_Radio","Camera Type_Speaker","Camera Type_Spy Camera","Collection_Spy Camera","Connectivity_WiFi\/Wireless","Features_Motion Activated","Features_Smartphone App","Live View_View Live Video","Location_Indoor","Location_Living Room","Location_Office \/ Business","Night Vision_Night Vision Enabled","OS Compatibility_Android","OS Compatibility_IOS","OS Compatibility_Windows","Power Source_Battery","Power Source_Plug In","Recording Source_Audio + Video","Storage - Maximum Capacity_128 Gb (16 Hrs Recording)","Storage Type_Cloud Recording (In-App)","Storage Type_Memory Card","Video Resolution - Max_Full HD 1080p","Viewing_Remote View"]}'); this.productsList.push(p); p = JSON.parse('{"handle":"aishine-weather-station-with-hd-1080p-motion-detection-security-camera","title":"[Refurb] Weather Station with HD 1080P Motion Detection Security Camera","status":"ACTIVE","tags":["Camera Megapixels_1MP","Camera Type_Appliance","Camera Type_Hidden","Camera Type_Nanny","Camera Type_Spy Camera","Collection_Spy Camera","Connectivity_WiFi\/Wireless","Features_App Push Notification","Features_Motion Activated","Features_Smartphone App","Field Of View_90 - 120 degrees","Live View_View Live Video","Location_Indoor","Location_Living Room","Location_Nursing Home","Location_Office \/ Business","OS Compatibility_Android","OS Compatibility_IOS","Power Source_Battery","Power Source_Plug In","Recording Source_Audio + Video","Sensor_CMOS","Storage - Maximum Capacity_128 Gb (16 Hrs Recording)","Storage Type_Memory Card","Video Resolution - Max_HD 720p","Viewing_Remote View"]}'); this.productsList.push(p); p = JSON.parse('{"handle":"1080p-diy-hidden-camera-tiny","title":"DIY Micro Hidden Camera","status":"ACTIVE","tags":["Application_LookCamPro","Battery Capacity_1000 mAH","Camera Megapixels_5MP","Camera Type_Hidden","Camera Type_Mini","Camera Type_Nanny","Camera Type_Pinhole","Camera Type_Spy Camera","Collection_Spy Camera","Connectivity_WiFi\/Wireless","DIY_DIY","Features_App Push Notification","Features_Motion Activated","Features_Smartphone App","Field Of View_0 - 90 degrees","Live View_View Live Video","Location_Indoor","Location_Living Room","Location_Office \/ Business","Location_Warehouse","OS Compatibility_Android","OS Compatibility_IOS","Power Source_Battery","Power Source_Plug In","Recording Source_Audio + Video","Sensor_CMOS","Storage - Maximum Capacity_32 Gb (4 Hrs Recording)","Storage Type_Cloud Recording (In-App)","Storage Type_Memory Card","Video Resolution - Max_Full HD 1080p","Viewing_Remote View"]}'); this.productsList.push(p); p = JSON.parse('{"handle":"hidden-camera-ac-adapter","title":"[Refurb] Hidden Camera AC Adapter","status":"ACTIVE","tags":["Application_TinyCam Pro","Battery Capacity_N\/A","Camera Type_AC Adapter","Camera Type_Appliance","Camera Type_Hidden","Camera Type_Mini","Camera Type_Nanny","Camera Type_Spy Camera","Collection_Spy Camera","Connectivity_WiFi\/Wireless","Features_Motion Activated","Features_Smartphone App","Field Of View_0 - 90 degrees","Live View_View Live Video","Location_Indoor","Location_Office \/ Business","OS Compatibility_Android","OS Compatibility_IOS","Power Source_Plug In","Recording Source_Audio + Video","Storage - Maximum Capacity_64 Gb (8 Hrs Recording)","Storage Type_Cloud Recording (In-App)","Storage Type_Memory Card","Video Resolution - Max_Full HD 1080p","Viewing_Remote View"]}'); this.productsList.push(p); p = JSON.parse('{"handle":"wi-fi-wireless-charging-dock-spy-camera","title":"Wi-Fi Wireless Charging Dock Spy Camera","status":"ACTIVE","tags":["Application_IOT Living","Battery Capacity_N\/A","Brand_Awaretech","Camera Megapixels_2MP","Camera Type_Charging Dock","Camera Type_Hidden","Camera Type_Nanny","Camera Type_Spy Camera","Collection_Spy Camera","Connectivity_WiFi\/Wireless","Features_App Push Notification","Features_Construction Time Lapse","Features_Smartphone App","Field Of View_90 - 120 degrees","Lens_2 mega pixels","Live View_View Live Video","Location_Dining Room","Location_Indoor","Location_Living Room","Location_Office \/ Business","Night Vision Range_0-10 Metres","Night Vision_Night Vision Enabled","OS Compatibility_Android","OS Compatibility_IOS","OS Compatibility_Windows","Power Source_Plug In","Recording Source_Audio + Video","Sensor_CMOS","Storage - Maximum Capacity_64 Gb (8 Hrs Recording)","Storage Type_Cloud Recording (In-App)","Storage Type_Memory Card","Video Resolution - Max_Full HD 1080p","Viewing_Remote View","Zoom_Digital"]}'); this.productsList.push(p); p = JSON.parse('{"handle":"diy-module-wi-fi-camera","title":"DIY Pinhole Module Wi-Fi Camera with Night Vision and Ultra Long Battery Life (Dual Battery Model))","status":"ACTIVE","tags":["Battery Capacity_2500 mAh","Brand_Awaretech","Camera Type_Hidden","Camera Type_Mini","Camera Type_Nanny","Camera Type_Pinhole","Camera Type_Spy Camera","Collection_Spy Camera","Connectivity_WiFi\/Wireless","DIY_DIY","Field Of View_120 - 180-degree","Live View_View Live Video","Location_Indoor","Location_Living Room","Location_Office \/ Business","Night Vision_Night Vision Enabled","Power Source_Battery","Recording Source_Audio + Video","Storage Type_Cloud Recording (In-App)","Storage Type_Memory Card","Video Resolution - Max_Full HD 1080p","Viewing_Remote View"]}'); this.productsList.push(p); p = JSON.parse('{"handle":"mobile-phone-wireless-charger-clock-inbuilt-security-camera","title":"Wireless Charger Camera Clock","status":"ACTIVE","tags":["Brand_Awaretech","Camera Type_Charging Dock","Camera Type_Clock","Camera Type_Hidden","Camera Type_Nanny","Camera Type_Spy Camera","Collection_Spy Camera","Connectivity_WiFi\/Wireless","Features_Motion Activated","Live View_View Live Video","Location_Dining Room","Location_Indoor","Location_Office \/ Business","Location_Warehouse","OS Compatibility_Android","OS Compatibility_IOS","OS Compatibility_Windows","Power Source_Battery","Power Source_Plug In","Recording Source_Audio + Video","Storage Type_Cloud Recording (In-App)","Storage Type_Memory Card","Video Resolution - Max_Full HD 1080p","Viewing_Remote View"]}'); this.productsList.push(p); p = JSON.parse('{"handle":"hd-pen-camera-audio-recorder-5-5hrs-battery-use","title":"Micro HD Pen Camera Audio Recorder-longest battery Use","status":"ACTIVE","tags":["Application_No App","Battery Capacity_160 mAh","Camera Type_Hidden","Camera Type_Mini","Camera Type_Nanny","Camera Type_Pen","Camera Type_Spy Camera","Camera Type_Wearable","Collection_Spy Camera","Features_No Phone Required","Field Of View_0 - 90 degrees","Location_Body Worn","Location_Indoor","Location_Office \/ Business","Location_Outdoor","OS Compatibility_Windows","Power Source_Battery","Recording Source_Audio + Video","Storage - Maximum Capacity_128 Gb (16 Hrs Recording)","Storage Type_Memory Card","Video Resolution - Max_HD 720p","Viewing_Memory Card Storage"]}'); this.productsList.push(p); p = JSON.parse('{"handle":"smoke-detector-hidden-camera-wifi-enabled","title":"Smoke Detector Hidden Camera - WiFi Enabled","status":"ACTIVE","tags":["Application_IOT Living","Battery Capacity_10000 mAH","Brand_Awaretech","Camera Megapixels_2MP","Camera Type_Hidden","Camera Type_Nanny","Camera Type_Smoke Detector","Camera Type_Spy Camera","Collection_Spy Camera","Connectivity_WiFi\/Wireless","Features_App Push Notification","Features_Motion Activated","Features_Smartphone App","Field Of View_120 - 180-degree","Lens_2 mega pixels","Live View_View Live Video","Location_Dining Room","Location_Indoor","Location_Living Room","Location_Office \/ Business","Night Vision Range_0-10 Metres","Night Vision_Night Vision Enabled","OS Compatibility_Android","OS Compatibility_IOS","OS Compatibility_Windows","Power Source_Battery","Power Source_Plug In","Recording Source_Audio + Video","Sensor_CMOS","Storage - Maximum Capacity_128 Gb (16 Hrs Recording)","Storage Type_Cloud Recording (In-App)","Storage Type_Memory Card","Video Resolution - Max_Full HD 1080p","Viewing_Remote View","Zoom_Digital"]}'); this.productsList.push(p); p = JSON.parse('{"handle":"power-bank-with-hidden-hd-camera-and-mic-fast-charging","title":"Power Bank with Hidden HD Camera and Mic - Portable Fast Charging","status":"ACTIVE","tags":["Application_IOT Living","Brand_Awaretech","Camera Type_Hidden","Camera Type_Mini","Camera Type_Nanny","Camera Type_Powerbank","Camera Type_Spy Camera","Camera Type_Surveillance","Collection_Spy Camera","Connectivity_WiFi\/Wireless","Features_Motion Activated","Features_Smartphone App","Live View_View Live Video","Location_Indoor","Location_Living Room","Location_Office \/ Business","OS Compatibility_Android","OS Compatibility_IOS","OS Compatibility_Windows","Power Source_Battery","Recording Source_Audio + Video","Storage - Maximum Capacity_64 Gb (8 Hrs Recording)","Storage Type_Cloud Recording (In-App)","Storage Type_Memory Card","Video Resolution - Max_Full HD 1080p","Viewing_Remote View"]}'); this.productsList.push(p); p = JSON.parse('{"handle":"z3-mini-body-camera-1080p-hd-hidden-spy-camera","title":"\ufeffZ3 Mini Body Camera - 1080P HD Hidden Spy Camera","status":"ACTIVE","tags":["Application_No App","Battery Capacity_1100 mAh","Camera Type_Body Worn","Camera Type_Clip On","Camera Type_Mini","Camera Type_Nanny","Camera Type_Spy Camera","Camera Type_Wearable","Collection_Spy Camera","Connectivity_WiFi\/Wireless","Features_Motion Activated","Features_No Phone Required","Field Of View_0 - 90 degrees","Live View_View Live Video","Location_Body Worn","Location_Indoor","New Arrivals","OS Compatibility_Windows","Power Source_Battery","Recording Source_Audio + Video","Storage - Maximum Capacity_32 Gb (4 Hrs Recording)","Storage Type_Cloud Recording (In-App)","Storage Type_Memory Card","Video Resolution - Max_Full HD 1080p","Viewing_Memory Card Storage"]}'); this.productsList.push(p); p = JSON.parse('{"handle":"4k-uhd-car-key-remote-spy-camera","title":"4K UHD Car Key Remote Spy Camera","status":"ACTIVE","tags":["Camera Type_Car Key FOB & Chain","Camera Type_Hidden","Camera Type_Mini","Camera Type_Nanny","Camera Type_Spy Camera","Camera Type_Wearable","Location_vehicle","New Arrivals","Video Resolution_UHD 2160p (4k)","Viewing_Memory Card Storage"]}'); this.productsList.push(p); p = JSON.parse('{"handle":"covert-pen-camera-records-in-full-hd","title":"\ufeff\ufeffCovert Pen Camera records in Full HD","status":"ACTIVE","tags":["Camera Type_Hidden","Camera Type_Mini","Camera Type_Nanny","Camera Type_Pen","Camera Type_Spy Camera","Camera Type_Wearable","Location_Body Worn","New Arrivals","Power Source_Battery","Storage - Maximum Capacity_128 Gb (16 Hrs Recording)","Storage - Maximum Capacity_16 GB","Storage Type_Internal Memory","Video Resolution_Full HD 1080p","Viewing_Memory Card Storage"]}'); this.productsList.push(p); p = JSON.parse('{"handle":"discreet-button-spy-camera","title":"Discreet Button Spy Camera","status":"ACTIVE","tags":["Camera Type_Body Worn","Camera Type_Button","Camera Type_Hidden","Camera Type_Mini","Camera Type_Nanny","Camera Type_Spy Camera","Features_No Phone Required","Location_Body Worn","New Arrivals","OS Compatibility_Windows","Power Source_Battery","Storage - Maximum Capacity_128 Gb (16 Hrs Recording)","Storage Type_Internal Memory","Video Resolution_Full HD 1080p"]}'); this.productsList.push(p); p = JSON.parse('{"handle":"4g-mini-cube-spy-camera","title":"\ufeff\ufeff4G Mini Cube Spy Camera with Night Vision","status":"ACTIVE","tags":["Battery Capacity_2500 mAh","Camera Features_Motion Activated","Camera Features_Smartphone App","Camera Features_Two-Way Audio","Camera Megapixels_2MP","Camera Type_Mini","Camera Type_Mini Cube","Camera Type_Nanny","Camera Type_Spy Camera","Colour_Black","Connectivity_4G Sim Enabled","Connectivity_WiFi\/Wireless","Location_Bedroom","Location_Dining Room","Location_Living Room","Location_Office \/ Business","Microphone_Built-In","Night Vision Range_0-5 Metres","Recording Source_Audio + Video","Storage - Maximum Capacity_256 Mb"]}'); this.productsList.push(p); p = JSON.parse('{"handle":"hidden-camera-ac-adapter-night-vision-adjustable","title":"Hidden Camera AC Adapter with Night Vision and Adjustable Lens Angle","status":"ACTIVE","tags":["Brand_Awaretech","Camera Features_Motion Activated","Camera Features_Smartphone App","Camera Type_AC Adapter","Camera Type_Hidden","Camera Type_Mini","Camera Type_Nanny","Camera Type_Spy Camera","Collection_Spy Camera","Colour_Black","Connectivity_WiFi\/Wireless","Features_Motion Activated","Features_Smartphone App","Field Of View_120 - 180-degree","Live View_View Live Video","Location_Bedroom","Location_Living Room","Location_Office \/ Business","Microphone_Built-In","Night Vision_Night Vision Enabled","OS Compatibility_Android","OS Compatibility_IOS"]}'); this.productsList.push(p); p = JSON.parse('{"handle":"spy-camera-usb-stick-with-invisible-lens","title":"Spy Camera USB Stick With Invisible Lens","status":"ACTIVE","tags":["Battery Capacity_300 mAh","Camera Features_No Internet Required","Camera Type_Body Worn","Camera Type_Hidden","Camera Type_Nanny","Camera Type_USB Stick","Camera Type_Wearable","Collection_Spy Camera","Colour_Black","Features_No Phone Required","Location_Body Worn","Location_Living Room","Location_Office \/ Business","Microphone_Built-In","Power Source_Battery","Recording Source_Audio + Video","Storage - Maximum Capacity_32 Gb (4 Hrs Recording)","Video Resolution - Max_Full HD 1080p"]}'); this.productsList.push(p); p = JSON.parse('{"handle":"4g-mini-cube-spy-camera-with-night-vision-v2","title":"4G Mini Cube Spy Camera with Night Vision","status":"ACTIVE","tags":["Battery Capacity_3000 mAh","Bedroom","Camera Features_Smartphone App","Camera Features_Two-Way Audio","Camera Megapixels_2MP","Camera Type_Hidden","Camera Type_Mini","Camera Type_Nanny","Camera Type_Spy Camera","Connectivity_4G Sim Enabled","Connectivity_WiFi\/Wireless","Featured","Features_Motion Activated","Features_Two-Way Audio","Location_Bedroom","Location_Dining Room","Location_Indoor","Location_Living Room","Location_Office \/ Business","Night Vision Range_0-5 Metres","Outdoor Camera Type_3G \/ 4G SIM Enabled","Recording Source_Audio + Video","Storage - Maximum Capacity_256 Mb"]}'); this.productsList.push(p); p = JSON.parse('{"handle":"4g-diy-mini-lens-wifi-camera-module","title":"Wireless WiFi & 4G Camera Security Module for DIY Surveillance","status":"ACTIVE","tags":["1080p Resolution","Battery Powered Spy Camera","Bedroom","Camera Features_Motion Activated","Camera Features_Smartphone App","Camera Megapixels_2MP","Camera Type_Mini","Camera Type_Nanny","Camera Type_Pinhole","Camera Type_Spy Camera","Camera Type_Surveillance","Collection_Spy Camera","Colour_Black","Connectivity_4G Sim Enabled","Connectivity_WiFi\/Wireless","DIY Pinhole Module Cameras","Features_App Push Notification","Features_Motion Activated","Location_Bedroom","Location_Dining Room","Location_Indoor","Location_Living Room","Location_Nursing Home","Night Vision Range_0-5 Metres","Night Vision Range_5m","OS Compatibility_Android","OS Compatibility_IOS","Power Source_Battery","Spy Cameras","Storage Type_Memory Card","Viewing_Remote View"]}'); this.productsList.push(p); p = JSON.parse('{"handle":"hd1080p-wireless-hidden-wall-mounted-security-camera","title":"HD 1080P Wireless Hidden Wall-mounted Hidden Camera with PIR Sensor","status":"ACTIVE","tags":["1080p Resolution","Badge: Hot","Badge: New","Battery Powered Spy Camera","Bedroom","Camera Features_Motion Activated","Camera Features_Smartphone App","Camera Features_Two-Way Audio","Camera Type_Hidden","Camera Type_Nanny","Camera Type_Spy Camera","Camera Type_Surveillance","Cheating Spouse","Collection_Outdoor","Collection_Spy Camera","Features_App Push Notification","Features_Motion Activated","Features_Smartphone App","Fleet Monitoring_In app monitoring","Location_Bedroom","Location_Dining Room","Location_Indoor","Location_Living Room","Location_Nursing Home","Location_Office \/ Business","Location_Outdoor","Location_Warehouse","Mount_Base mount","New Arrivals","Night Vision Range_0-5 Metres","OS Compatibility_Android","OS Compatibility_IOS","Spy Cameras","Video Playback Viewing_Memory Stored","Video Playback Viewing_Remote View"]}'); this.productsList.push(p); p = JSON.parse('{"handle":"camera-clock-with-adjustable-angle","title":"Smart Alarm Clock Spy Camera 1080P\/2K\/4K Full HD with Remote Night Vision & Motion Detection","status":"ACTIVE","tags":["1080p Resolution","Battery Capacity_3000 mAh","Camera Type_Clock","Camera Type_Hidden","Camera Type_Nanny","Collection_Spy Camera","Colour_Black","Connectivity_WiFi\/Wireless","Features_Loop Recording","Features_Motion Activated","Features_Smartphone App","Field Of View_120 - 180-degree","Live View_View Live Video","Location_Bedroom","Location_Dining Room","Location_Indoor","Location_Living Room","Location_Nursing Home","Location_Office \/ Business","Location_Warehouse","Night Vision Range_0-10 Metres","Night Vision Range_5m","Night Vision_Night Vision Enabled","OS Compatibility_Android","OS Compatibility_IOS","Power Source_Battery","Power Source_Plug In","Spy Cameras","Storage - Maximum Capacity_256 Mb","Storage Type_Memory Card","Video Playback Viewing_Memory Stored","Video Playback Viewing_Remote View","Video Resolution_Full HD 1080p","Viewing_Memory Card Storage","Viewing_Remote View"]}'); this.productsList.push(p); p = JSON.parse('{"handle":"1080p-wifi-nanny-cam-picture-frame-with-ir-night-vision-and-super-long-battery-life","title":"1080P WIFI Nanny Cam Picture Frame with IR Night Vision and Super Long Battery Life","status":"ACTIVE","tags":["1080p Resolution","Battery Capacity_1000 mAH","Battery Powered Spy Camera","Camera Features_Motion Activated","Camera Features_Smartphone App","Camera Type_Nanny","Cheating Spouse","Collection_Spy Camera","Colour_Black","Connectivity_WiFi\/Wireless","Features_App Push Notification","Features_Motion Activated","Features_Smartphone App","Field Of View_0 - 90 degrees","Location_Bedroom","Location_Dining Room","Location_Indoor","Location_Living Room","Location_Nursing Home","Location_Office \/ Business","New Arrivals","OS Compatibility_Android","OS Compatibility_IOS","Power Source_Battery","Recording Source_Audio + Video","Storage Type_Memory Card"]}'); this.productsList.push(p); p = JSON.parse('{"handle":"tuya-series-4k-smart-alarm-clock-spy-camera-with-discreet-mirror-display","title":"[Tuya Series] 4K Smart Alarm Clock Spy Camera with Discreet Mirror Display","status":"ACTIVE","tags":["1080p Resolution","Battery Powered Spy Camera","Bedroom","Camera Features_Motion Activated","Camera Features_Smartphone App","Camera Type_Clock","Camera Type_Hidden","Camera Type_Nanny","Camera Type_Spy Camera","Camera Type_Surveillance","Collection_Spy Camera","Colour_Black","Connectivity_WiFi\/Wireless","Features_App Push Notification","Features_Loop Recording","Features_Motion Activated","Features_Smartphone App","Field Of View_120 - 180-degree","Location_Bedroom","Location_Dining Room","Location_Indoor","Location_Living Room","Location_Nursing Home","Location_Office \/ Business","Location_Warehouse","Microphone_Built-In","Night Vision Range_0-5 Metres","Night Vision_Night Vision Enabled","Office\/Business","OS Compatibility_Android","OS Compatibility_IOS","Power Source_Battery","Spy Cameras","Storage Type_Cloud Storage","Storage Type_Memory Card","Video Resolution_Full HD 1080p"]}'); this.productsList.push(p); p = JSON.parse('{"handle":"tuya-series-4k-table-alarm-clock-camera-with-night-vision-and-remote-viewing","title":"[Tuya Series] 4K Table Alarm Clock Camera with Night Vision and Remote Viewing","status":"ACTIVE","tags":["1080p Resolution","Battery Powered Spy Camera","Bedroom","Camera Features_Motion Activated","Camera Features_Smartphone App","Camera Type_Clock","Camera Type_Nanny","Camera Type_Spy Camera","Cheating Spouse","Collection_Spy Camera","Colour_Black","Connectivity_WiFi\/Wireless","Features_App Push Notification","Features_Loop Recording","Features_Motion Activated","Features_Smartphone App","Field Of View_120 - 180-degree","Location_Bedroom","Location_Dining Room","Location_Indoor","Location_Living Room","Location_Nursing Home","Location_Office \/ Business","Location_Warehouse","Microphone_Built-In","night vision","Night Vision Range_0-5 Metres","Night Vision_Night Vision Enabled","Office\/Business","OS Compatibility_Android","OS Compatibility_IOS","Power Source_Battery","Power Source_Plug In","Storage Type_Cloud Storage","Storage Type_Memory Card","Viewing_Remote View"]}'); this.productsList.push(p); p = JSON.parse('{"handle":"tuya-series-4k-mini-desktop-clock-camera-with-invisible-lens-motion-detection-and-night-vision","title":"[Tuya Series] 4K Mini Desktop Clock Camera with Invisible Lens, Motion Detection and Night Vision","status":"ACTIVE","tags":["1080p Resolution","Battery Powered Spy Camera","Camera Features_Motion Activated","Camera Features_Smartphone App","Camera Type_Clock","Camera Type_Hidden","Camera Type_Nanny","Camera Type_Spy Camera","Collection_Spy Camera","Colour_Black","Connectivity_WiFi\/Wireless","Features_App Push Notification","Features_Loop Recording","Features_Motion Activated","Features_Smartphone App","Field Of View_120 - 180-degree","Live View_View Live Video","Location_Bedroom","Location_Dining Room","Location_Indoor","Location_Living Room","Location_Nursing Home","Location_Office \/ Business","Location_Warehouse","Microphone_Built-In","Mount_Free standing","night vision","Night Vision Range_0-5 Metres","Night Vision_Night Vision Enabled","Office\/Business","OS Compatibility_Android","OS Compatibility_IOS","Power Source_Battery","Power Source_Plug In","Spy Cameras","Storage Type_Cloud Storage","Storage Type_Memory Card","Storage_Memory Card","Video Resolution_Full HD 1080p","Viewing_Remote View"]}'); this.productsList.push(p); p = JSON.parse('{"handle":"smart-power-adaptor-camera-with-night-vision-and-motion-detection-us-plug-with-au-adaptor","title":"Smart Power Adaptor Camera with Night Vision and Motion Detection (AU Plug)","status":"ACTIVE","tags":["1080p Resolution","Camera Features_Motion Activated","Camera Features_Smartphone App","Camera Type_AC Adapter","Camera Type_Nanny","Collection_Spy Camera","Colour_Silver","Connectivity_WiFi\/Wireless","Features_Loop Recording","Features_Motion Activated","Features_Smartphone App","Location_Bedroom","Location_Dining Room","Location_Indoor","Location_Living Room","Location_Nursing Home","Location_Office \/ Business","New Arrivals","Night Vision Range_0-5 Metres","Office\/Business","OS Compatibility_Android","OS Compatibility_IOS","Power Source_Plug In","Storage Type_Memory Card","Video Resolution_Full HD 1080p"]}'); this.productsList.push(p); p = JSON.parse('{"handle":"1080p-hd-wifi-streaming-nanny-cam-air-purifier","title":"1080P HD WiFi Streaming Nanny Cam Air Purifier","status":"ACTIVE","tags":["Bedroom","Camera Features_Motion Activated","Camera Features_Smartphone App","Camera Type_Nanny","Cheating Spouse","Collection_Spy Camera","Colour_Black","Connectivity_WiFi\/Wireless","Features_Motion Activated","Features_Smartphone App","Live View_View from Memory","Live View_View Live Video","Location_Bedroom","Location_Dining Room","Location_Indoor","Location_Living Room","Location_Nursing Home","Location_Office \/ Business","night vision","Night Vision Range_0-5 Metres","OS Compatibility_Android","OS Compatibility_IOS","Power Source_Plug In","Spy Cameras","Storage Type_Memory Card","Storage_Memory Card","Video Resolution_Full HD 1080p","Viewing_Remote View"]}'); this.productsList.push(p); p = JSON.parse('{"handle":"mini-magnetic-wi-fi-camera-1080p-security-camera-with-night-vision-and-motion-detection","title":"Mini Magnetic Wi-Fi 1080P Security Camera with Night Vision and Motion Detection","status":"ACTIVE","tags":["Battery Capacity_800 mAh","Battery Powered Spy Camera","Bedroom","Camera Features_Motion Activated","Camera Features_Smartphone App","Camera Megapixels_1MP","Camera Type_Button","Camera Type_Mini","Camera Type_Nanny","Camera Type_Spy Camera","Cheating Spouse","Collection_Spy Camera","Colour_Black","Connectivity_WiFi\/Wireless","Features_App Push Notification","Features_Loop Recording","Features_Motion Activated","Features_Smartphone App","Field Of View_90 - 120 degrees","Live View_View from Memory","Live View_View Live Video","Location_Bedroom","Location_Dining Room","Location_Indoor","Location_Living Room","Location_Nursing Home","Location_Office \/ Business","Location_Warehouse","Microphone_Built-In","Mount_Base mount","Night Vision Range_0-5 Metres","Night Vision_Night Vision Enabled","OS Compatibility_Android","OS Compatibility_IOS","Power Source_Battery","Storage Type_Cloud Storage","Storage Type_Memory Card","Storage_Memory Card","Video Resolution - Max_Full HD 1080p","Viewing_Memory Card Storage"]}'); this.productsList.push(p); } catch(e){ console.error(e); } } checkFilterItems() { let allTags = []; for(let i = 0; i < this.productsList.length; i++) { let productTags = this.productsList[i]['tags']; allTags = allTags.concat(productTags); } Array.from(this.filterItems).forEach(function(element){ let tagName = element.dataset.tag; let text = element.innerText; let parent = element.parentElement; if(!allTags.includes(tagName)) { parent.remove(); }else { let counts = []; allTags.forEach(function (x) { counts[x] = (counts[x] || 0) + 1; }); let newText = text + ' (' + counts[tagName] + ')'; element.innerText = newText; } }, this); let ul_elements = document.getElementsByClassName("tag-list--order"); Array.from(ul_elements).forEach(function(ul){ if(ul.children.length < 1) { let group = ul.parentElement.parentElement.parentElement; group.style.display = "none"; } }); } render(resetCurrentPage = false){ if(resetCurrentPage) { this.currentPage = 1; } let productPerPage = this.limit; let end_index = this.currentPage * productPerPage; let start_index = end_index - productPerPage; if(this.tagsFilter.length < 1) { while (this.productsContainer.firstChild) this.productsContainer.removeChild(this.productsContainer.firstChild); if(this.newData.length > 0) { this.data = this.newData; }else { this.data = this.productsList; } this.data = this.formatData(this.sortType, this.data); let stop_index = 0; if(this.data.length > (this.currentPage*productPerPage)) { stop_index = end_index }else{ stop_index = this.data.length; } if(this.currentPage > 1) { this.productsContainer.style.height = this.containerHeight + 'px'; } this.progress = 0; this.loadProductsGrid(start_index, stop_index, this.data); }else { this.data = []; for (let i = 0; i < this.newData.length; i++) { let productTags = this.newData[i]['tags']; let is_passed = false; for(let j = 0; j < this.tagsFilter.length; j++) { if(productTags.includes(this.tagsFilter[j])) { is_passed = true; } } if(is_passed) { this.data.push(this.newData[i]); } } while (this.productsContainer.firstChild) this.productsContainer.removeChild(this.productsContainer.firstChild); if(this.data.length > 0) { let stop_index = 0; if(this.data.length > (this.currentPage*productPerPage)) { stop_index = end_index }else{ stop_index = this.data.length; } if(this.currentPage > 1) { this.productsContainer.style.height = this.containerHeight + 'px'; } this.progress = 0; this.data = this.formatData(this.sortType, this.data); this.loadProductsGrid(start_index, stop_index, this.data); }else{ let notfound = '

Sorry, there are no products in this tags.

'; this.productsContainer.innerHTML = notfound; } } let pagination = this.productsContainer.parentElement.getElementsByClassName('pagination')[0]; if(pagination != undefined) { this.productsContainer.parentElement.removeChild(pagination); } if(this.data.length > this.limit) { this.createPagination(this.data); } } loadProductsGrid(start, stop, data){ let number_product = stop - start; for(let i = start; i < stop; i++) { let url = window.location.origin + '/products/' + data[i].handle + "?view=grid-item-new"; fetch(url) .then((res) => { if(res.status == 404){ return false; } return res.text(); }) .then(res => this.showProduct(res, i, number_product)) .catch(err => console.log(err)); } } showProduct(res, i, number_product){ this.progress++; let doc = this.parser.parseFromString(res, 'text/html'); let product = doc.querySelector(".grid-product"); let layout = ''; let items_layout = document.getElementsByClassName('item-layout'); for(let i = 0; i < items_layout.length; i++) { if(items_layout[i].classList.contains('active')) { layout = items_layout[i].dataset.layout; } } if(product != null) { product.style.display = 'flex'; product.style.order = i + 1; product.classList.add(layout + '-active'); this.productsContainer.append(product); let compare = product.querySelector('.SPCMP_Add_span'); if(compare != null) { compare.innerText = 'COMPARE'; } let add_to_cart = product.querySelector('.grid-product__add-to-cart'); if(add_to_cart != null) { add_to_cart.addEventListener('click', function(e){ e.preventDefault(); let a_element = e.target.closest('a'); if(!a_element.classList.contains('added')) { a_element.classList.add('added'); let variant_id = a_element.dataset.variant; let formData = { 'items': [{ 'id': variant_id, 'quantity': 1 }] }; theme.cart.addItemFromForm(formData); window.addEventListener('cartUpdate', function(){ let site_url = window.location.origin; window.location.replace(site_url + '/cart'); }); } }); } } if(this.progress == number_product) { this.productsContainer.setAttribute('style', ''); this.scrollToTop(); } } createPagination(data = []) { if(data.length > 0) { this.totalPage = data.length / this.limit; }else{ this.totalPage = this.data.length / this.limit; } if(!Number.isInteger(this.totalPage ) || this.totalPage == 0) { this.totalPage += 1; } let pagination = document.createElement('div'); pagination.classList.add('pagination'); let html = ''; if(this.currentPage > 1 && this.totalPage > 1) { html += ''; html += ''; html += ''; html += ''; html += ''; } for(let i = 1; i <= this.totalPage; i++) { if(this.currentPage == i) { html += ''+ i +''; }else{ html += ''+ i +''; } } if(this.currentPage < parseInt(this.totalPage)) { html += ''; html += ''; html += ''; html += ''; html += ''; } pagination.innerHTML = html; this.productsContainer.parentElement.appendChild(pagination); let pagination_item = pagination.querySelectorAll('.page a'); Array.from(pagination_item).forEach(function(element){ element.addEventListener("click", this.actionPagination.bind(this)); }, this); } actionPagination(e) { e.preventDefault(); this.currentPage = e.target.closest('a').dataset.page; let current_height = this.productsContainer.offsetHeight; this.containerHeight = current_height; this.render(); } getTagsFilter(e) { console.log(this.newData); let tag = e.target.dataset.tag; Array.from(this.filterItems).forEach(function(element){ let tag_e = element.dataset.tag; let parent_e = element.parentElement; if(parent_e.classList.contains('tag--active') && tag_e == tag) { parent_e.classList.remove('tag--active'); this.removeRedTag(tag); let index = this.tagsFilter.indexOf(tag); if (index !== -1) { this.tagsFilter.splice(index, 1); } }else if (!parent_e.classList.contains('tag--active') && tag_e == tag) { parent_e.classList.add('tag--active'); let is_added = false; let tagListActiveItems = document.querySelectorAll('.tag--remove'); if(tagListActiveItems.length > 0) { Array.from(tagListActiveItems).forEach(function(item){ if(item.dataset.tag == tag) { is_added = true; } }, this); } if(!is_added) { this.addRedTag(tag); } if(!this.tagsFilter.includes(tag)) { this.tagsFilter.push(tag); } } this.btnOpenFilterText.innerText = 'Filter (' + this.tagsFilter.length + ')'; }, this); if (this.tagsFilter.length > 0 && !this.btnOpenFilterMobile.classList.contains('btn--tertiary-active')) { this.btnOpenFilterMobile.classList.add('btn--tertiary-active'); } else if (this.tagsFilter.length < 1){ this.btnOpenFilterMobile.classList.remove('btn--tertiary-active'); this.btnOpenFilterText.innerText = 'Filter'; } this.data = []; this.render(true); if (theme.FilterDrawer) { theme.FilterDrawer.close(); } } addRedTag(tag) { let tag_arr = tag.split('_'); let html = ''+ tag_arr[1] +''; html += ''; let li_element = document.createElement('li'); li_element.classList.add('tag','tag--remove'); li_element.dataset.tag = tag; li_element.innerHTML = html; Array.from(this.tagListActive).forEach(function(ul){ let duplicatedE = li_element.cloneNode(true); ul.appendChild(duplicatedE); this.actionRemoveRedTag(duplicatedE); }.bind(this)); } removeRedTag(tag) { Array.from(this.tagListActive).forEach(function(ul){ let tags_remove = ul.getElementsByTagName('li'); for(let i = 0; i < tags_remove.length; i++) { if(tags_remove[i].dataset.tag == tag) { ul.removeChild(tags_remove[i]); } } }.bind(this)); } actionRemoveRedTag(element) { let redTag = element.querySelector('span'); redTag.addEventListener("click", function(e){ let tag_remove = redTag.parentElement.dataset.tag; let index = this.tagsFilter.indexOf(tag_remove); if (index !== -1) { this.tagsFilter.splice(index, 1); } this.removeRedTag(tag_remove); Array.from(this.filterItems).forEach(function(item){ let tag = item.dataset.tag; if(tag == tag_remove && item.parentElement.classList.contains('tag--active')) { item.parentElement.classList.remove('tag--active'); } }); if (this.tagsFilter.length < 1){ this.btnOpenFilterMobile.classList.remove('btn--tertiary-active'); this.btnOpenFilterText.innerText = 'Filter'; } else { this.btnOpenFilterText.innerText = 'Filter (' + this.tagsFilter.length + ')'; } this.data = []; this.render(); }.bind(this)); } showSortList(e) { e.preventDefault(); let sortby_panel = document.getElementById("sortby-panel"); let sortby_overlay = document.getElementById("sortby-overlay"); if(sortby_panel.classList.contains("show_panel")) { sortby_panel.classList.remove("show_panel"); sortby_overlay.classList.remove("active"); }else{ sortby_panel.classList.add("show_panel"); sortby_overlay.classList.add("active"); } } sortHandler(e) { e.preventDefault(); let li_element = e.currentTarget; let a_element = li_element.querySelector('a'); let value = a_element.dataset.value; let item_name = ''; Array.from(this.sortItems).forEach(function(item){ let a_item = item.querySelector('a'); if(a_item.dataset.value == value && !item.classList.contains("sortby-item--selected")) { item.classList.add("sortby-item--selected"); item_name = item.getElementsByClassName('sortby-item-name')[0].innerText; }else{ item.classList.remove("sortby-item--selected"); } }, this); this.dataset.sort = value; this.sortType = value; let current_sortby = this.sortSelect.getElementsByClassName('current-sortby')[0]; current_sortby.innerText = 'Sort: ' + item_name; this.render(); let sortby_panel = document.getElementById("sortby-panel"); let sortby_overlay = document.getElementById("sortby-overlay"); if(sortby_panel.classList.contains("show_panel")) { sortby_panel.classList.remove("show_panel"); sortby_overlay.classList.remove("active"); } } formatData(type, data) { switch (type) { case 'title-ascending': data.sort((a, b) => a.title.localeCompare(b.title) || b.price - a.price); break; case 'title-descending': data.sort((a, b) => b.title.localeCompare(a.title) || b.price - a.price); break; case 'price-ascending': data.sort((a, b) => a.price - b.price); break; default: data.sort((a, b) => b.price - a.price); break; } return data; } scrollToTop() { let scrollHeight = this.productsContainer.offsetTop; window.scrollTo({ top: scrollHeight - 200, behavior: 'smooth'}); } } customElements.define("pce-products-dev", PCE_Products_DEV);